package com.wenx;

import io.netty.bootstrap.ServerBootstrap;
import io.netty.channel.Channel;
import io.netty.channel.ChannelFuture;
import io.netty.channel.EventLoopGroup;
import io.netty.channel.nio.NioEventLoopGroup;
import io.netty.channel.socket.nio.NioServerSocketChannel;
import io.netty.channel.socket.nio.NioSocketChannel;

public class ServerMain {

    public static void main(String[] args) {
        EventLoopGroup boossGroup = new NioEventLoopGroup();
        EventLoopGroup worderGroup = new NioEventLoopGroup();
        try {
            ServerBootstrap bootstrap = new ServerBootstrap();
            bootstrap.group(boossGroup,worderGroup)
                    .channel(NioServerSocketChannel.class)
                    .childHandler(new MyWebSocketChannelHander());
            ChannelFuture future = bootstrap.bind(8888).sync();
            System.out.println("服务端已启动...");
            future.channel().closeFuture().sync();
        } catch (InterruptedException e) {
            e.printStackTrace();
        } finally {
            boossGroup.shutdownGracefully();
            worderGroup.shutdownGracefully();
        }


    }

}
